import java.util.Random;

public class Main {

    private static double testStack(Stack<Integer> stack,int opCount){

        long startTime = System.nanoTime();

        //...
        Random random = new Random();
        for (int i = 0; i < opCount; i++) {
            stack.push (random.nextInt(Integer.MAX_VALUE));//将[0-Max]其中的一数传进

        }

        for (int i = 0; i < opCount; i++) {
            stack.pop ();
        }
        long endTime = System.nanoTime();


        return (endTime - startTime) / 1000000000.0;
    }


    public static void main(String[] args) {
        int opCount = 10000000;
        ArrayStack<Integer> arrayQueue = new ArrayStack<>();
        double time1 = testStack (arrayQueue,opCount);
        System.out.println("ArrayStack,time:"+time1+"s");

        LinkedListStack<Integer> loopqueue = new LinkedListStack <> ();
        double time2 = testStack(loopqueue,opCount);
        System.out.println("LinkedListStack,time:"+time2+"s");

    }
}
